added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSVSPackageMonitorFileChange / ReadMe.txt
blobc9f8b6c4041b7a965bcf037811efabc3f9bf86ac
1 ================================================================================
2        VSX application : CSVSPackageMonitorFileChange Project Overview                        
3 ===============================================================================
5 /////////////////////////////////////////////////////////////////////////////
6 Use:
8 Visual Studio provides SVsFileChangeEx service enables arbitrary components 
9 to register to be notified when a file is modified outside of the Environment.
11 This service is useful when you are performing some operation which will be 
12 interupted by file changes from outside environment.
14 The service is similar with FileSystemWatcher Class.
15 http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
17 To use this sample, follow the steps as below:
19 1. Start experimental VS instance
20 2. The package will be autoloaded automatically when there is no any solution 
21 loaded.
22 3. The demo monitors user's desktop directory, so please do file or directory 
23 changes in desktop.
24 4. Visual Studio will popup window whenever a change is made.
27 //////////////////////////////////////////////////////////////////////////////
28 Prerequisites:
30 VS 2008 SDK must be installed on the machine. You can download it from:
31 http://www.microsoft.com/downloads/details.aspx?FamilyID=30402623-93ca-479a-867c-04dc45164f5b&displaylang=en
33 Otherwise the project may not be opened by Visual Studio.
35 If you run this project on a x64 OS, please also config the Debug tab of the project
36 Setting. Set the "Start external program" to 
37 C:\Program Files(x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
39 NOTE: The Package Load Failure Dialog occurs because there is no PLK(Package Load Key)
40       Specified in this package. To obtain a PLK, please to go to WebSite:
41       http://msdn.microsoft.com/en-us/vsx/cc655795.aspx
42       More info
43       http://msdn.microsoft.com/en-us/library/bb165395.aspx
45 /////////////////////////////////////////////////////////////////////////////
47 Steps:
48 In order to implement this sample, following are the core steps:
49 (For detailed informaiton, please view sample code)
51 1. Create package class and specify AutoLoad attribute:
52 [ProvideAutoLoad("{adfc4e64-0397-11d1-9f4e-00a0c911004f}")]
53 adfc4e64-0397-11d1-9f4e-00a0c911004f represents context that there is 
54 no solution is loaded.
56 2. In the package's initializate method, add following code:
58 IVsFileChangeEx fileChangeService =
59     GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
60 monitor = new CSVSMonitorFileChange();
61 uint cookie;
63 // Enables a client to receive notifications of changes to a directory.
64 fileChangeService.AdviseDirChange(
66     // String form of the moniker identifier of 
67     // the directory in the project system.
68     Environment.GetFolderPath(
69         Environment.SpecialFolder.Desktop),
71     // If true, then events should also be fired 
72     // for changes to sub directories. If false, 
73     // then events should not be fired for changes 
74     // to sub directories.
75     Convert.ToInt32(true),
77     // IVsFileChangeEvents Interface on the object 
78     // requesting notification of file change events.
79     monitor,
81     // Unique identifier for the file that is 
82     // associated with the event sink.
83     out cookie
86 3. Implements CSVSMonitorFileChange class which inherited from IVsFileChangeEvents
87 Implements DirectoryChanged and FilesChanged methods to popup message box
88 when a change is monitored.
90 /////////////////////////////////////////////////////////////////////////////
91 References:
93 How to get notifications in editor when the file is modified outside of the editor?
94 http://blogs.msdn.com/dr._ex/archive/2005/11/01/487721.aspx
96 IVsFileChangeEvents Interface
97 http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsfilechangeevents.aspx
99 SVsFileChangeEx Interface
100 http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.svsfilechangeex(VS.80).aspx
102 FileSystemWatcher Class
103 http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx